package com.example.demo.rabbitmq;


import com.rabbitmq.client.ConnectionFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {


    @Value("${rabbitmqUserName}")
    private String rabbitmqUserName;
    @Value("${rabbitmqPassword}")
    private String rabbitmqPassword;
    @Value("${virtualHost}")
    private String virtualHost;
    @Value("${rabbitmqHost}")
    private String rabbitmqHost;
    @Value("${rabbitmqPort}")
    private String rabbitmqPort;


    @Bean
    public ConnectionFactory connection() {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setUsername(rabbitmqUserName);
        factory.setPassword(rabbitmqPassword);
        factory.setVirtualHost(virtualHost);
        factory.setHost(rabbitmqHost);
        factory.setPort(Integer.parseInt(rabbitmqPort));
        return factory;
    }


}
